﻿using System;
using System.Data;
using System.Web.UI.WebControls;

namespace LKCMS.Web
{
    public partial class Navigation : System.Web.UI.UserControl
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                Bind();
            }
        }

        private void Bind()
        {
            LKCMS.BLL.Channel cll = new LKCMS.BLL.Channel();
            LKCMS.Model.Channel model = new LKCMS.Model.Channel();
            this.DropDownList1.Items.Add(new ListItem("- 请选择您的出游目的地 -", "-1"));
            DataTable dt = cll.GetListNew(" ParentId =1");
            if (dt.Rows.Count > 0)
            {
                this.DropDownList1.Items.Add(new ListItem("四川旅游", "BigType.aspx?id=1"));
                foreach (DataRow dr in dt.Rows)
                {
                    ListItem li = new ListItem("┣四川_" + dr["Title"].ToString(), "NormalType.aspx?id=" + dr["ID"].ToString());
                    this.DropDownList1.Items.Add(li);
                }
            }

            DataTable dt1 = cll.GetListNew(" ParentId =2");
            if (dt1.Rows.Count > 0)
            {
                this.DropDownList1.Items.Add(new ListItem("国内旅游", "BigType.aspx?id=2"));
                foreach (DataRow dr in dt1.Rows)
                {
                    ListItem li = new ListItem("┣国内_" +dr["Title"].ToString(), "NormalType.aspx?id=" + dr["ID"].ToString());
                    this.DropDownList1.Items.Add(li);
                }
            }

            DataTable dt2 = cll.GetListNew(" ParentId =3");
            if (dt2.Rows.Count > 0)
            {
                this.DropDownList1.Items.Add(new ListItem("境外旅游", "BigType.aspx?id=3"));
                foreach (DataRow dr in dt2.Rows)
                {
                    ListItem li = new ListItem("┣境外_" +dr["Title"].ToString(), "NormalType.aspx?id=" + dr["ID"].ToString());
                    this.DropDownList1.Items.Add(li);
                }
            }

        
        }
        protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e)
        {
            Response.Redirect(DropDownList1.SelectedItem.Value);
        }
    }
}